/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author stumbledog
 */
@Entity
@Table(name = "fantasyuser")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fantasyuser.findAll", query = "SELECT f FROM Fantasyuser f"),
    @NamedQuery(name = "Fantasyuser.findById", query = "SELECT f FROM Fantasyuser f WHERE f.id = :id"),
    @NamedQuery(name = "Fantasyuser.findByPassword", query = "SELECT f FROM Fantasyuser f WHERE f.password = :password"),
    @NamedQuery(name = "Fantasyuser.findByEmail", query = "SELECT f FROM Fantasyuser f WHERE f.email = :email"),
    @NamedQuery(name = "Fantasyuser.findByLoginName", query = "SELECT f FROM Fantasyuser f WHERE f.loginName = :loginName")})
public class Fantasyuser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "password")
    private String password;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "email")
    private String email;
    @Size(max = 45)
    @Column(name = "loginName")
    private String loginName;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ownerUserId")
    private Collection<Fantasyleague> fantasyleagueCollection;
    @OneToMany(mappedBy = "userId")
    private Collection<Fantasyteam> fantasyteamCollection;

    public Fantasyuser() {
    }

    public Fantasyuser(Integer id) {
        this.id = id;
    }

    public Fantasyuser(Integer id, String password, String email) {
        this.id = id;
        this.password = password;
        this.email = email;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    @XmlTransient
    public Collection<Fantasyleague> getFantasyleagueCollection() {
        return fantasyleagueCollection;
    }

    public void setFantasyleagueCollection(Collection<Fantasyleague> fantasyleagueCollection) {
        this.fantasyleagueCollection = fantasyleagueCollection;
    }

    @XmlTransient
    public Collection<Fantasyteam> getFantasyteamCollection() {
        return fantasyteamCollection;
    }

    public void setFantasyteamCollection(Collection<Fantasyteam> fantasyteamCollection) {
        this.fantasyteamCollection = fantasyteamCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fantasyuser)) {
            return false;
        }
        Fantasyuser other = (Fantasyuser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Fantasyuser[ id=" + id + " ]";
    }
    
}
